home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_gen / gcoope10.zip / FILE.C < prev    next >
Text File  |  1994-07-21  |  907b  |  54 lines

  1.  
  2. /*
  3.  
  4.     File object class definition for GCOOPE10
  5.  
  6.       released as PUBLIC DOMAIN 4/25/94 ported and modified 7/21/94
  7.  
  8. */
  9.  
  10.  
  11.  
  12. #define CLASS File
  13.  
  14. #include "gcoope10.h"
  15. #include <stdio.h>
  16.  
  17. object CLASS;
  18.  
  19. extern object StdStream;
  20.  
  21. USEGEN(addressOf);
  22.  
  23.  
  24. cmethod object m4New(object instance, const char * fnam, const char * mode)
  25. {
  26. if(NULL==makeInst(&instance)) return 0L;
  27. g(New)(ST(StdStream), fopen(fnam, mode));
  28. return instance;
  29. }
  30.  
  31.  
  32. cmethod object m4Kill(object instance)
  33. {
  34. FILE * handle;
  35.  
  36. handle=((VDPTRRV)g)(GEN(addressOf))(instance);
  37. if(handle!=NULL)
  38.     {
  39.     fclose(handle);
  40.     }
  41. g(Kill)(ST(StdStream));
  42. g(Kill)(Object, instance);
  43. return instance;
  44. }
  45.  
  46.  
  47. CLASS_INSTALL
  48. {
  49. if(END==(CLASS=g(New)(Class, 0, 0, StdStream, END))
  50.    || addGMthd(CLASS, New, (method) m4New)
  51.    || addGMthd(CLASS, Kill, (method) m4Kill)) return FUNCFAIL;
  52. else return FUNCOKAY;
  53. }
  54.